<template>
  <div class="search-colllapse-pro">
    <div class="title">
      <div class="l">
        <slot name="title"></slot>
      </div>
      <div class="r" @click="triggerCollapse" v-if="isAdvSearch">
        <span class="title-pro-font" v-show="isSearch">{{$t(advSearch)}}</span>
        <div></div>
        <div class="icon" v-show="iconShow">
          <i :class="['icon-arrow', 'el-icon-arrow-right', isActive ? 'is-active' : '']"></i>
        </div>
      </div>
    </div>
    <el-collapse-transition>
      <div v-show="queryCollapseStatus" class="collapse">
        <slot name="collapse"></slot>
      </div>
    </el-collapse-transition>
  </div>
</template>
<script>
export default {
  /**
   *  搜索面板组件
   */
  name: 'SearchCollapsePro',
  props: {
    // 是否是查询类型
    isSearch: {
      type: Boolean,
      default: true
    },
    // 是否显示右边icon
    iconShow: {
      type: Boolean,
      default: true
    },
    // 是否默认展开
    defaultCollapse: {
      type: Boolean,
      default: false
    },
    // 是否需要高级搜索
    isAdvSearch : {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {
      isActive: this.defaultCollapse,
      advSearch: 'cm.advancedSearch',
      queryCollapseStatus: this.defaultCollapse
    }
  },
  created () {
  },
  methods: {
    triggerCollapse () {
      this.queryCollapseStatus = !this.queryCollapseStatus
      if (this.queryCollapseStatus) { // 展开 收缩
        this.advSearch = "cm.return"
        this.isActive = true
      } else {
        this.advSearch = "cm.advancedSearch"
        this.isActive = false
      }
    }
  },
  watch: {
  }
}
</script>
<style lang="scss">
.search-colllapse-pro {
  // padding: 0px 20px;
  background-color: $--color_white;
  // border-bottom: 1px solid $--border_color;
  border-top: 1px solid $--border_color;
  .title {
    padding: 0px 10px;
    height: 50px;
    border-bottom: 1px solid $--border_color;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap; // 不允许换行
    justify-content: space-between;
    
    .l {
      display: flex;
      flex-direction: row;
      flex-wrap: none;
      justify-content: start;
      align-items: center;
      // width: 100%;
    }
    .r {
      cursor: pointer;
      // width: 100%;
      flex: 1;
      height: 50px;
      line-height: 50px;
      display: flex;
      flex-direction: row;
      flex-wrap: none;
      justify-content: space-between;
      .icon {
        display: inline-block;
        .icon-arrow {
          transition: transform .3s;
        }
        .icon-arrow.is-active {
          transform: rotate(90deg);
        }
      }
    }
  }
  .collapse {
    padding: 20px;
     .el-input input{ 
      padding-right: 30px;
    }
  }
}
</style>
